package org.example.route.controller.UserController;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.example.route.model.dto.ShoppingShowDTO;
import org.example.route.model.pojo.Result;
import org.example.route.model.vo.ShoppingShowVO;
import org.example.route.service.ShoppingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/shopping")
@Slf4j
@Tag(name = "购物车管理")
public class ShoppingController {
    @Autowired
    private ShoppingService shoppingService;


    //TODO 用户查看购物车
    //可以直接调用Order中的方法
    @Operation(summary = "查看购物车")
    @PostMapping("/list/{userId}")
    public Result list(@PathVariable("userId")Long userId)//传过来的是用户的id，获取该用户的所有购物车信息

    {
        log.info("查看此用户购物车的信息，{}", userId);

        List<ShoppingShowVO> shoppingShowVOS = shoppingService.list(userId);

        return Result.success(shoppingShowVOS);


    }


}
